package com.gwcd.myapplication.service;

import android.app.Service;
import android.content.Intent;
import android.graphics.Color;
import android.os.Binder;
import android.os.IBinder;

import androidx.annotation.Nullable;

import java.util.Random;

public class MyService extends Service {
    private MyBinder myBinder = new MyBinder();
    private Random random = new Random();

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return myBinder;
    }

    public int getRandomColor() {
        byte[] bytes = new byte[3];
        random.nextBytes(bytes);
        return Color.argb(0xFF, 0xFF & bytes[0], 0xFF & bytes[1], 0xFF & bytes[2]);
    }

    public class MyBinder extends Binder {
        public MyService getService() {
            return MyService.this;
        }
    }
}
